﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Model.Manager;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
namespace Enterprise.Data.Manager
{
    /// <summary>
    /// 经理信箱回复数据表操作类
    /// </summary>
    public class MsgReplyData
    {
        /// <summary>
        ///  经理信箱回复数据列表
        /// </summary>
        /// <returns></returns>
        public List<MsgReplyEntity> MsgReplyList(int msgId)
        {
            List<MsgReplyEntity> list = new List<MsgReplyEntity>();
            string cmd = "Select * from MANAGER_MSGREPLY where MSGID=" + msgId;
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                MsgReplyEntity entity = new MsgReplyEntity();
                if (!Convert.IsDBNull(dr["REPLYID"])) entity.ReplyId = Convert.ToInt32(dr["REPLYID"]);
                if (!Convert.IsDBNull(dr["MSGID"])) entity.MsgId = Convert.ToInt32(dr["MSGID"]);
                if (!Convert.IsDBNull(dr["REPLYCONTENT"])) entity.ReplyContent = Convert.ToString(dr["REPLYCONTENT"]);
                if (!Convert.IsDBNull(dr["REPLYISSHOW"])) entity.ReplyIsShow = Convert.ToInt32(dr["REPLYISSHOW"]);
                if (!Convert.IsDBNull(dr["REPLYIP"])) entity.ReplyIp = Convert.ToString(dr["REPLYIP"]);
                if (!Convert.IsDBNull(dr["REPLYTIME"])) entity.ReplyTime = Convert.ToDateTime(dr["REPLYTIME"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 经理信箱回复数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void MsgReplyExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

    }
}
